import os
import multiprocessing
import time

def copy(name,old_file_name,new_file_name):
    print(1)
    with open (old_file_name +'/'+ name,'rb') as f1:
        content = f1.read()
    with open (new_file_name +'/'+ name,'wb') as f2:
        f2.write(content)
        
def main():
    # 获取想要复制的文件夹名称
    old_file_name = 'D:\python\jichuu\多任务\进程\\'+input('请输入名称:')
    # 获取文件夹下的所有文件名称
    names=os.listdir(old_file_name)
    # 创建新的文件夹
    try:
        new_file_name = old_file_name + '[new]'
        os.mkdir(new_file_name)
    except:
        pass
    # 创建进程池
    po = multiprocessing.Pool(5)
    # 把任务加入进程池
    for name in names:
        po.apply_async(copy,(name,old_file_name,new_file_name))

    po.close()
    po.join()
    time.sleep(2)
        
if __name__ == "__main__":
    main()
